<template>
	<view>
		<view class="head">
			<text class="title">账户余额(元)</text>
			<text class="num" v-cloak>{{res.credit}}</text>
			<view class="kefu">
			<!-- <view class="kefu" @tap="openLink"> -->
				有疑问<image src="../../static/coinhelp.png" mode=""></image>
			</view>
		</view>
		<view class="uni-list">
			<view class="uni-list-cell" @click="jumprecharge">
				<view class="uni-list-cell-navigate uni-navigate-right">
					充值
				</view>
			</view>
			<view class="uni-list-cell" @click="jumpLog">
				<view class="uni-list-cell-navigate uni-navigate-right">
					充值记录
				</view>
			</view>
		</view>
		<view class="list">
			<text class="title">未完成订单</text>
			<view class="uni-list">
				<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(value,key) in res.orderlist" :key="key" @click="jump" :data-id="value.id">
					<view class="uni-media-list uni-pull-right">
						<view class="uni-media-list-logo mid">
							<text>充值中</text>
						</view>
						<view class="uni-media-list-body">
							<view class="uni-media-list-text-top">
							<text v-if="value.coin == 'bank'">银行卡充值：</text>
							<text v-else-if="value.coin == 'alipay'">支付宝充值：</text>
							<text v-else-if="value.coin == 'wchat'">微信充值：</text v-cloak>{{value.money}}元</view>
							<view class="uni-media-list-text-bottom uni-ellipsis" v-cloak>{{value.createtime}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				res:[],
				openid:""
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=coin.balance&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						this.res = res.data
						uni.hideLoading()
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump(e){
				uni.navigateTo({
					url: 'c2cdetail?id='+e.currentTarget.dataset.id
				});
			},
			jumpLog(){
				uni.navigateTo({
					url: 'log?cointitle=c2c'
				});
			},
			jumprecharge(){
				uni.navigateTo({
					url: 'recharge'
				});
			}
		}
	}
</script>
<style>.head text{display:block;}.uni-media-list-logo.mid{width:auto;}.head .kefu{font-size:24upx;color:#ace2e0;line-height:44upx;}.head .num{font-size:74upx;font-weight:600;line-height:120upx;}.list .title{text-align:center;display:block;padding:24upx;color:#666;}.head{background:#175e3c;color:#e2fcfb;text-align:center;padding:40upx;}.head .kefu image{width:32upx;height:32upx;position:relative;top:6upx;margin-left:6upx;}.uni-media-list-logo.mid text{font-size:24upx;color:#fff;background:#ff9326;padding:0 10upx;box-sizing:content-box;}</style>